/***************************************************************************
 * This code is an original creation. It is intended to be used for a one  *
 * reader, one card situation within the Micro Framework. This is intended *
 * to be used with the GemCore Serial Lite Pro evaluation board or the     *
 * Teridian 73S1209F evaluation board, unless a device class is created    *
 * to work with another evaluation board.                                  *
 * LAST MODIFIED: 2010 April 23                                            *
 * Copyright (C) 2009 Gemalto                                              *
 ***************************************************************************/
/***************************************************************************
 *  Reader.cs is part of the PC/SC Micro API for the .NET Micro            *
 *  Framework.                                                             *
 *                                                                         *
 *  The PC/SC Micro API for the .NET Micro Framework is free software:     *
 *  you can redistribute it and/or modify it under the terms of the GNU    *
 *  General Public License as published by the Free Software Foundation,   *
 *  either version 2 of the License, or (at your option) any later version.*
 *                                                                         *
 *  The PC/SC Micro API for the .NET Micro Framework is distributed in     *
 *  the hope that it will be useful, but WITHOUT ANY WARRANTY; without even*
 *  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR    *
 *  PURPOSE.  See the GNU General Public License for more details.         *
 *                                                                         *
 *  You should have received a copy of the GNU General Public License      *
 *  along with the PC/SC Micro API for the .NET Micro Framework. If not,   *
 *  see <http://www.gnu.org/licenses/>.                                    *
 ***************************************************************************/

using System;
using Microsoft.SPOT;

namespace PCSCMicro
{
    internal abstract class Reader
    {
        internal enum ReaderError
        {
            NONE, READER_OFF, SHARING_VIOLATION, CARD_DEACTIVATED, PORT_CONNECTION_FAILED, TEST_RUNNING,
            ACTIVATING_CARD, NO_CARD_INSERTED, BAD_PROTOCOL, ALREADY_CONNECTED, NO_TEST_RUNNING, NO_RESPONSE,
            BAD_MESSAGE, BAD_COMMAND, CARD_MALFUNCTION, UNKNOWN_ERROR
        }

        // Connect reader
        internal abstract bool ConnectReader();

        // Disconnect reader
        internal abstract bool DisconnectReader();

        // Reset reader
        internal abstract bool ResetReader();

        // Send User SlotStatus if able to update, otherwise -1
        internal abstract int GetStatus();

        // Activate card
        internal abstract bool ActivateCard();

        // Send PPS with user defined parameters
        internal abstract bool SendPPS(byte protocol);

        // Deactivate card
        internal abstract bool DeactivateCard();

        // Reset card
        internal abstract bool ResetCard();

        // Checks to see if reader is Connected or not
        internal abstract bool IsReaderActive();

        // Executes a Command given as a parameter
        internal abstract string ExecuteCommand(string commandCode, string data);

        // Get current error
        internal abstract ReaderError Error {get;}

        // Get ATR
        internal abstract string ATR {get;}

        // Checks for errors, then calls APDUProcedures
        internal abstract string SendAPDU(string apduText);
    }
}
